// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

import gameData from "../gameData";
import AudioManage, {soundList} from "../../framework/AudioManage";

const {ccclass, property} = cc._decorator;

@ccclass
export default class enterTimes extends cc.Component {

    @property(cc.Node)
    cancelNode : cc.Node = null;

    @property(cc.Node)
    picNode : cc.Node = null;

    @property(cc.Node)
    titleNode : cc.Node = null;

    @property(cc.Node)
    handNode : cc.Node = null;

    @property(cc.Node)
    enterNode : cc.Node = null;


    onLoad(){
        AudioManage.playLevelMusic(soundList.levelBG, true);
        AudioManage.playLevelMusic(soundList.vortex, false);
        cc.tween(this.picNode)
            .to(0.3,{scale : 1})
            .delay(0.2)
            .call(()=>{
                cc.tween(this.titleNode)
                    .to(0.1,{scale : 1})
                    .delay(0.2)
                    .call(()=>{
                        this.enterNode.active = true;
                    })
                    .delay(0.2)
                    .call(()=>{
                        this.handNode.active = true;
                    })
                    .start();
            }).start();
        this.scheduleOnce(()=>{
            this.cancelNode.active = true;
        },10);
    }

    onClick(event,data){
        if(parseInt(data) == 1){
            if(gameData.getRoleProcessSkin()[14] == 0){
                cc.director.loadScene("sp3");
            }else{
                cc.director.loadScene("sp3_1");
            }
            AudioManage.playLevelMusic(soundList.vortex, false);
        }

        if(parseInt(data) == 2){
            this.node.destroy();
            AudioManage.playLevelMusic(soundList.vortex, true);
            AudioManage.playLevelMusic(soundList.levelBG, false);
        }
    }

    protected update(dt: number): void {
        this.picNode.angle += 2;
    }
}
